//
//  WDDBankBusinessView.m
//  SZBank
//
//  Created by rimi on 16/7/14.
//  Copyright © 2016年 LuoYao. All rights reserved.
//

#import "WDDBankBusinessView.h"
#import "CustomerNavigationBars.h"
#import "AccountSavingView.h"
#import "WDDElectronicBankView.h"
#import "BankCardView.h"
#import "PaymentView.h"
#import "InternetbankView.h"
#import "MobilebankView.h"
#import "MessageNotificationView.h"
#import "LoanInterestView.h"
#import "BJDepositRateView.h"
#import "BJLoanBusiness.h"
#define COMMON_RECT CGRectMake(KWIDTH * 0.04, KHEIGHT * 0.08, KWIDTH * 0.82, KHEIGHT * 0.77)
@interface WDDBankBusinessView()<CustomerNavigationBarsDelegate>
{
    CGFloat frameWidth;/**  自身宽度 */
    CGFloat frameHeight;/**  自身高度 */
}

@property (nonatomic,strong) CustomerNavigationBars *topButtons;/**  顶部滑动按钮 */

@property (nonatomic,strong) UIScrollView *topScrollerView;/**  顶部滑动视图 */

@property (nonatomic) AccountSavingView *accountSaving;/**  储蓄存款 */

@property (nonatomic) LoanInterestView *loanInterest;/**  贷款利率 */

@property (nonatomic) WDDElectronicBankView *electronicBank;/**  电子银行 */

@property (nonatomic) BankCardView *bankCard;/**  银行卡 */

@property (nonatomic) PaymentView *payment;/**  日常缴费 */

@property (nonatomic) InternetbankView *internetbank;/**  个人网银 */

@property (nonatomic) MobilebankView *mobilebank;/**  手机银行 */

@property (nonatomic) MessageNotificationView *notification;/**  短信通知 */

@property (nonatomic) BJDepositRateView *depositRate;/**< 存款利率 */

@property (nonatomic)BJLoanBusiness *loanBusiness;/**< 贷款业务 */
@end
@implementation WDDBankBusinessView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        frameWidth = self.frame.size.width;
        frameHeight = self.frame.size.height;
        [self addSubview:self.backgroundImage];
        [self addSubview:self.topScrollerView];
        [self.topScrollerView addSubview:self.topButtons];
        self.accountSaving = [[AccountSavingView alloc] initWithFrame:COMMON_RECT];
        [self addSubview:self.accountSaving];
    }
    return self;
}

- (void)customeNavigationBarView:(CustomerNavigationBars *)customeNavigationBarView didSelectButton:(UIButton *)didSelectButton{
    /**  移除上一个视图 */
    if (![[[self subviews] lastObject] isKindOfClass:[UIScrollView class]]){
        [[[self subviews] lastObject] removeFromSuperview];
    }
    switch(didSelectButton.tag - 1000){
        case 0:
        {
            self.accountSaving = [[AccountSavingView alloc] initWithFrame:COMMON_RECT];
            [self addSubview:self.accountSaving];
        }
            break;
        case 1:{
            [self addSubview:self.depositRate];
        }
            break;
        case 2:{
            [self addSubview:self.loanBusiness];
        }
            break;
        case 3:
        {
            self.loanInterest = [[LoanInterestView alloc] initWithFrame:COMMON_RECT];
            [self addSubview:self.loanInterest];
        }
            break;
        case 4:
        {
            self.electronicBank = [[WDDElectronicBankView alloc] initWithFrame:COMMON_RECT];
            [self addSubview:self.electronicBank];
        }
            break;
        case 5:
        {
            self.bankCard = [[BankCardView alloc] initWithFrame:COMMON_RECT];
            [self addSubview:self.bankCard];
        }
            break;
        case 6:
        {
            self.payment = [[PaymentView alloc] initWithFrame:COMMON_RECT];
            [self addSubview:self.payment];
        }
            break;
        case 7:
        {
            self.internetbank = [[InternetbankView alloc] initWithFrame:COMMON_RECT];
            [self addSubview:self.internetbank];
        }
            break;
        case 8:
        {
            self.mobilebank = [[MobilebankView alloc] initWithFrame:COMMON_RECT];
            [self addSubview:self.mobilebank];
        }
            break;
        case 9:
        {
            self.notification = [[MessageNotificationView alloc] initWithFrame:COMMON_RECT];
            [self addSubview:self.notification];
        }
            break;
        default:
            break;
    }
}

- (UIImageView *)backgroundImage{
    if (!_backgroundImage) {
        _backgroundImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, frameWidth, frameHeight)];
        _backgroundImage.image = [LocalDataManager getImageWithSourceOfPath:@"背景"];
    }
    return _backgroundImage;
}

- (CustomerNavigationBars *)topButtons{
    if (!_topButtons) {
        _topButtons = [[CustomerNavigationBars alloc] initWithFrame:CGRectMake(0, 0, frameWidth, frameHeight * 0.05)];
        NSArray *titleArray = @[@"储蓄存款",@"存款利率",@"个人贷款",@"贷款利率",@"电子银行",@"银行卡",@"日常缴费",@"个人网银",@"手机银行",@"短信通知"];
        _topButtons = [[CustomerNavigationBars alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, KHEIGHT * 0.06) btnTitleArray:titleArray];
        _topButtons.delegate = self;
        
    }
    return _topButtons;
}

- (UIScrollView *)topScrollerView{
    if (!_topScrollerView) {
        _topScrollerView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, frameWidth, frameHeight * 0.06)];
        _topScrollerView.contentSize = CGSizeMake(1.01 * frameWidth, frameHeight * 0.05);
        _topScrollerView.backgroundColor = [UIColor clearColor];
        _topScrollerView.showsHorizontalScrollIndicator = NO;
    }
    return _topScrollerView;
}

- (BJDepositRateView *)depositRate{
    if (!_depositRate) {
        _depositRate = [[BJDepositRateView alloc]initWithFrame:CGRectMake(KWIDTH * 0.04, KHEIGHT * 0.08, KWIDTH * 0.82, KHEIGHT * 0.77)];
        _depositRate.backgroundColor = [UIColor clearColor];
    }
    return _depositRate;
}

- (BJLoanBusiness *)loanBusiness{
    if (!_loanBusiness) {
        _loanBusiness = [[BJLoanBusiness alloc]initWithFrame:CGRectMake(KWIDTH * 0.04, KHEIGHT * 0.08, KWIDTH * 0.82, KHEIGHT * 0.77)];
    }
    return _loanBusiness;
}
@end
